package com.xwaf.platform.system.provider.serviceimpl.hander;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xwaf.platform.system.api.entity.hander.TradeOrder;
import com.xwaf.platform.system.api.service.hander.TradeOrderHandler;
import com.xwaf.platform.system.api.service.hander.TradeOrderHandlerChain;
import com.xwaf.platform.system.api.service.hander.TradeOrderService;

@Service("tradeOrderService")
public class TradeOrderServiceImpl implements TradeOrderService {

	@Autowired
	private InventoryExpHandler inventoryExpHandler;

	@Autowired
	private WeightExpHanlder weightExpHanlder;

	public TradeOrder checkOrder() {
		// 订单责任链
		List<TradeOrderHandler> autoAdds = new ArrayList<TradeOrderHandler>();
		autoAdds.add(inventoryExpHandler);
		autoAdds.add(weightExpHanlder);
		TradeOrderHandlerChain autoAddChain = new TradeOrderHandlerChainServiceImpl();
		autoAddChain.setHanlders(autoAdds.iterator());
		TradeOrder tradeOrder = new TradeOrder();
		autoAddChain.doProcess(tradeOrder);
		return tradeOrder;
	}
}
